/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.bomt.utils;

import com.comac.ins.bomt.domain.vo.DetailStandardBomVo;
import com.comac.ins.bomt.domain.vo.DetailStatusStrengthChangeVo;
import com.comac.ins.bomt.domain.vo.DetailStrengthBomVo;
import com.comac.ins.bomt.domain.vo.DetailStrengthStandardChangeVo;

import java.util.List;
import java.util.Objects;

/**
 * bom版本工具
 *
 * @author zhanghongyi
 * @date 2024 /9/4
 * @description BomVersionUtil
 */
public class BomVersionUtil {
    /**
     * Gets versions.
     *
     * @param detailList the detail list
     * @return the versions
     */
    public static List<String> getVersions(List<?> detailList) {
        return detailList.stream().map(item -> {
            if (item instanceof DetailStatusStrengthChangeVo itemVo) {
                return itemVo.getVersion();
            }
            if (item instanceof DetailStrengthStandardChangeVo itemVo) {
                return itemVo.getVersion();
            }
            if (item instanceof DetailStandardBomVo itemVo) {
                return itemVo.getVersion();
            }
            if (item instanceof DetailStrengthBomVo itemVo) {
                return itemVo.getVersion();
            }
            return null;
        }).filter(Objects::nonNull).distinct().sorted().toList();
    }
}
